﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SQLite;

namespace LiteFrame
{
    public class BL_Users
    {
        SQLiteCommand cmdObj;
        // 用户注册
        public SQLiteCommand Register(User UserInfo)
        {
            cmdObj = new SQLiteCommand();
            cmdObj.CommandText = @"INSERT INTO Users VALUES (@ID, @LogCode, @LogPass, @NickName, @Email)";
            cmdObj.Parameters.AddWithValue("@ID", UserInfo.ID);
            cmdObj.Parameters.AddWithValue("@LogCode",UserInfo.LogCode);
            cmdObj.Parameters.AddWithValue("@LogPass", UserInfo.LogPass);
            cmdObj.Parameters.AddWithValue("@NickName",UserInfo.NickName);
            cmdObj.Parameters.AddWithValue("@Email",UserInfo.Email);
            return cmdObj;
        }

        public SQLiteCommand Login(User UserInfo)
        {
            cmdObj = new SQLiteCommand();
            cmdObj.CommandText = @"SELECT ID, NickName, Email FROM Users WHERE LogCode = @LogCode AND LogPass = @LogPass";
            cmdObj.Parameters.AddWithValue("@LogCode", UserInfo.LogCode);
            cmdObj.Parameters.AddWithValue("@LogPass", UserInfo.LogPass);
            return cmdObj;
        }
    }
}
